package com.aspose.cells.a.d.b;

import com.aspose.cells.a.d.a.zc;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Paint;
import java.awt.Shape;
import java.awt.Stroke;
import java.awt.geom.Point2D;
import java.awt.geom.Ellipse2D.Double;

public class za {
   public static Color a(Color var0) {
      return var0 == null ? null : new Color(var0.getRed(), var0.getGreen(), var0.getBlue(), var0.getAlpha());
   }

   public static Font a(Font var0) {
      return var0 == null ? null : new Font(var0.getName(), var0.getSize(), var0.getSize());
   }

   public static Paint a(Paint var0) {
      if (var0 == null) {
         return null;
      } else if (var0 instanceof Color) {
         Color var2 = (Color)var0;
         return new Color(var2.getRed(), var2.getGreen(), var2.getBlue(), var2.getAlpha());
      } else if (var0 instanceof GradientPaint) {
         GradientPaint var1 = (GradientPaint)var0;
         return new GradientPaint(var1.getPoint1(), var1.getColor1(), var1.getPoint2(), var1.getColor2(), var1.isCyclic());
      } else {
         return var0;
      }
   }

   public static Stroke a(Stroke var0) {
      if (var0 == null) {
         return null;
      } else if (var0 instanceof BasicStroke) {
         BasicStroke var1 = (BasicStroke)var0;
         return new BasicStroke(var1.getLineWidth(), var1.getEndCap(), var1.getLineJoin(), var1.getMiterLimit(), var1.getDashArray(), var1.getDashPhase());
      } else {
         return var0;
      }
   }

   public static void a(zc var0, double var1, double var3, double var5, double var7, Point2D var9, Point2D var10, Color var11, Color var12) throws Exception {
      int var13 = var11.getRed();
      int var14 = var11.getGreen();
      int var15 = var11.getBlue();
      int var16 = var12.getRed();
      int var17 = var12.getGreen();
      int var18 = var12.getBlue();
      double var19 = 30.0D;
      double var21 = 1.5D;
      double var23;
      double var25;
      double var27;
      double var29;
      double var31;
      int var33;
      int var34;
      int var35;
      Color var36;
      if (var9.getX() == var10.getX()) {
         var23 = var9.getY();
         var25 = Math.abs(var10.getY() - var9.getY());
         var27 = 1.0D;
         if (var25 < var19) {
            var27 = var25 / var19;
         }

         var29 = (var10.getY() - var9.getY()) / Math.abs(var10.getY() - var9.getY());
         var0.setStroke(new BasicStroke((float)Math.abs(var27 * var21)));

         for(var31 = 0.0D; var31 < var25 + var27 / 2.0D; var23 += var29 * var27) {
            var33 = (int)((double)var13 + (double)(var16 - var13) * (var31 / var25));
            var34 = (int)((double)var14 + (double)(var17 - var14) * (var31 / var25));
            var35 = (int)((double)var15 + (double)(var18 - var15) * (var31 / var25));
            var36 = a(var33, var34, var35);
            var0.setColor(var36);
            var0.b(var1, var23, var1 + var5, var23);
            var31 += var27;
         }
      } else if (var9.getY() == var10.getY()) {
         var23 = var9.getX();
         var25 = Math.abs(var10.getX() - var9.getX());
         var27 = 1.0D;
         if (var25 < var19) {
            var27 = var25 / var19;
         }

         var29 = (var10.getX() - var9.getX()) / Math.abs(var10.getX() - var9.getX());
         var0.setStroke(new BasicStroke((float)Math.abs(var27 * var21)));

         for(var31 = 0.0D; var31 < var25 + var27 / 2.0D; var23 += var29 * var27) {
            var33 = (int)((double)var13 + (double)(var16 - var13) * (var31 / var25));
            var34 = (int)((double)var14 + (double)(var17 - var14) * (var31 / var25));
            var35 = (int)((double)var15 + (double)(var18 - var15) * (var31 / var25));
            var36 = a(var33, var34, var35);
            var0.setColor(var36);
            var0.b(var23, var3, var23, var3 + var7);
            var31 += var27;
         }
      } else {
         var23 = (var10.getY() - var9.getY()) / (var10.getX() - var9.getX());
         var25 = Math.tan(Math.atan2(var10.getY() - var9.getY(), var10.getX() - var9.getX()) + 1.5707963267948966D);
         var27 = var9.getX();
         var29 = var23 * (var27 - var9.getX()) + var9.getY();
         var31 = var25 * (var1 - var27) + var29;
         double var53 = var25 * (var1 + var5 - var27) + var29;
         var27 = var10.getX();
         var29 = var23 * (var10.getX() - var9.getX()) + var9.getY();
         double var54 = var25 * (var1 - var10.getX()) + var29;
         double var37 = 0.0D;
         double var39 = Math.abs(var54 - var31);
         double var41 = 1.0D;
         if (var39 < var19) {
            var41 = var39 / var19;
         }

         double var43 = (var54 - var31) / Math.abs(var54 - var31);
         var0.setStroke(new BasicStroke((float)Math.abs(var41 * var21)));

         while(var37 <= var39 + var41 / 2.0D) {
            int var45 = (int)((double)var13 + (double)(var16 - var13) * (var37 / var39));
            int var46 = (int)((double)var14 + (double)(var17 - var14) * (var37 / var39));
            int var47 = (int)((double)var15 + (double)(var18 - var15) * (var37 / var39));
            Color var48 = a(var45, var46, var47);
            var0.setColor(var48);
            double var49 = var31 + var43 * var37;
            double var51 = var53 + var43 * var37;
            var0.b(var1, var49, var1 + var5, var51);
            var37 += var41;
         }
      }

   }

   public static void a(Graphics var0, Shape var1, Point2D var2, float var3, float[] var4, Color[] var5) {
      Graphics2D var6 = null;
      Graphics2D var7 = null;

      try {
         var6 = (Graphics2D)var0.create();
         var6.clip(var1);
         var7 = (Graphics2D)var6.create();
         double var8 = 0.0D;
         double var10 = var2.getX() - var8;
         double var12 = var2.getY() - var8;
         double var14 = 30.0D;
         double var16 = 1.5D;

         for(int var18 = 1; var18 < var5.length; ++var18) {
            Color var19 = var5[var18 - 1];
            Color var20 = var5[var18];
            int var21 = var19.getRed();
            int var22 = var19.getGreen();
            int var23 = var19.getBlue();
            int var24 = var20.getRed();
            int var25 = var20.getGreen();
            int var26 = var20.getBlue();
            double var27 = (double)((var4[var18] - var4[var18 - 1]) * var3);
            double var29 = 1.0D;
            if (var27 < var14) {
               var29 = var27 / var14;
            }

            var7.setStroke(new BasicStroke((float)Math.abs(var29 * var16)));

            for(double var31 = 0.0D; var31 < var27 + var29 / 2.0D; var8 += var29) {
               int var33 = (int)((double)var21 + (double)(var24 - var21) * (var31 / var27));
               int var34 = (int)((double)var22 + (double)(var25 - var22) * (var31 / var27));
               int var35 = (int)((double)var23 + (double)(var26 - var23) * (var31 / var27));
               Color var36 = a(var33, var34, var35);
               var7.setColor(var36);
               if (var8 > 0.0D) {
                  Double var37 = new Double(var10, var12, 2.0D * var8, 2.0D * var8);
                  var7.draw(var37);
               }

               var31 += var29;
               var10 -= var29;
               var12 -= var29;
            }
         }
      } catch (Exception var41) {
         System.out.print(var41.getMessage());
      } finally {
         if (var7 != null) {
            var7.dispose();
         }

         if (var6 != null) {
            var6.dispose();
         }

      }

   }

   private static Color a(int var0, int var1, int var2) {
      if (var0 < 0) {
         var0 = 0;
      }

      if (var0 > 255) {
         var0 = 255;
      }

      if (var1 < 0) {
         var1 = 0;
      }

      if (var1 > 255) {
         var1 = 255;
      }

      if (var2 < 0) {
         var2 = 0;
      }

      if (var2 > 255) {
         var2 = 255;
      }

      return new Color(var0, var1, var2);
   }
}
